import config from './config';
export default (url, data = {}, method = "GET") => {
  return new Promise((resolve, reject) => {
    wx.request({
      method,
      url: config.baseUrl + url, 
      data,
      header:{
        cookie:wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item=>item.indexOf('MUSIC_U')!=-1):""
      },
      success(res) {
        if(data.isLogin){
          wx.setStorageSync('cookies', res.cookies)
        }

        resolve(res.data)
      },
      fail(res) {
        reject(res)
      }
    })
  })
}